using System;
using System.Collections;

namespace OpenDentBusiness{
	#region notes to self 
	//Possible structure of recalltype table:
	//RecallTypeNum: primary key
	//Description
	//DefaultInterval
	//TimePattern: for scheduling the appointment
	//Procedures: what procedures to put on that appointment. comma delimited.
	
	//a procedure could be attached to one recall type, keeping the link as a field in the procedurecode table, or it could be attached to multiple recall types, requiring a linking table.  In either case, the interface will be from the recall setup window.
	#endregion	
	///<summary>Max one per patient.  A patient can only have one recall date set for each type (there is currently only one type).  The recall table stores a few dates that must be kept synchronized with other information in the database.  This is difficult.  Anytime one of the following items changes, things need to be synchronized: procedurecode.SetRecall, any procedurelog change for a patient (procs added, deleted, completed, status changed, date changed, etc), patient status changed.  There are expected to be a few bugs in the synchronization logic, so anytime a patient's recall is opened, it will also update.
	///
	///During synchronization, the program will frequently alter DateDueCalc, DateDue, and DatePrevious based on trigger procs.  The system will also add and delete recalls as necessary. But it will not delete a recall unless all values are default and there is no useful information.  When a user tries to delete a recall, they will only be successful if the trigger conditions do not apply.  Otherwise, they will have to disable the recall instead.</summary>
	public class Recall{
		///<summary>Primary key.</summary>
		public int RecallNum;
		///<summary>FK to patient.PatNum.</summary>
		public int PatNum;
		///<summary>Not editable.  The calculated date due. Generated by the program and subject to change anytime the conditions change. It can be blank (0001-01-01) if no appropriate triggers. </summary>
		public DateTime DateDueCalc;
		///<summary>This is the date that is actually used when doing reports for recall. It will usually be the same as DateDueCalc unless user has changed it. System will only update this field if it is the same as DateDueCalc.  Otherwise, it will be left alone.  Gets cleared along with DateDueCalc when resetting recall.  When setting disabled, this field will also be cleared.  This is the field to use if converting from another software.</summary>
		public DateTime DateDue;
		///<summary>Not editable. Previous date that procedures were done to trigger this recall. It is calculated and enforced automatically.  If you want to affect this date, add a procedure to the chart with a status of C, EC, or EO.</summary>
		public DateTime DatePrevious;
		///<summary>The interval between recalls.  The Interval struct combines years, months, weeks, and days into a single integer value.</summary>
		public Interval RecallInterval;
		///<summary>FK to Definition.DefNum, or 0 for none.</summary>
		public int RecallStatus;
		///<summary>An administrative note for staff use.</summary>
		public string Note;
		///<summary>If true, this recall type will be disabled (there's only one type right now). This is usually used rather than deleting the recall type from the patient because the program must enforce the trigger conditions for all patients.</summary>
		public bool IsDisabled;
		//Type: RecallType, once we have multiple recall types

		///<summary>Returns a copy of this Recall.</summary>
		public Recall Copy(){
			Recall recall=new Recall();
			recall.RecallNum=RecallNum;
			recall.PatNum=PatNum;
			recall.DateDueCalc=DateDueCalc;
			recall.DateDue=DateDue;
			recall.DatePrevious=DatePrevious;
			recall.RecallInterval=RecallInterval;
			recall.RecallStatus=RecallStatus;
			recall.Note=Note;
			recall.IsDisabled=IsDisabled;
			return recall;
		}

	}

}









